/*
 * jQuery File Upload Plugin JS Example 6.11
 * https://github.com/blueimp/jQuery-File-Upload
 *
 * Copyright 2010, Sebastian Tschan
 * https://blueimp.net
 *
 * Licensed under the MIT license:
 * http://www.opensource.org/licenses/MIT
 */

/*jslint nomen: true, unparam: true, regexp: true */
/*global $, window, document */

$(function () {
    'use strict';

    // Initialize the jQuery File Upload widget:
    $('#fileupload').fileupload({
		
        // Uncomment the following to send cross-domain cookies:
        //xhrFields: {withCredentials: true},
        url:'./data/video/video/index.php?id='+id+''
    });
	
	  $('#fileupload2').fileupload({
        // Uncomment the following to send cross-domain cookies:
        //xhrFields: {withCredentials: true},
        url:'./data/video/soustitre/index.php?id='+id
    });
	
	$('#fileupload').bind('fileuploaddestroy', function (e, data) {
	 if (!confirm("Attention voulez vous vraiment supprimer la video?")){ 
	 
	 // Clic sur OK
      /*    $.get
		(
			"./ajax/supprimer_upload_video.php",
			{
					id: id
			}

		);*/
      }

	});
	

		 

	
	
	

	
	
	$('#fileupload2').fileupload('option', {
            acceptFileTypes: /(\.|\/)(srt)$/i,
			uploadTemplateId: 'template-upload2',
            // The ID of the download template:
            downloadTemplateId: 'template-download2',
			filesContainer: '#containersrt',
			
			
			  });
	
	  $('#fileupload3').fileupload({
        // Uncomment the following to send cross-domain cookies:
        //xhrFields: {withCredentials: true},
        url: './framework/fileupload/server/php/uploadvignette/'
    });
	
	  $('#fileupload2').fileupload({
        // Uncomment the following to send cross-domain cookies:
        //xhrFields: {withCredentials: true},
        url: './data/video/soustitre/',
    });
	

	
	  $('#fileupload3').fileupload({
        // Uncomment the following to send cross-domain cookies:
        //xhrFields: {withCredentials: true},
        url: './framework/fileupload/server/php/uploadvignette/'
    });
	
	$('#fileupload3').fileupload('option', {
            acceptFileTypes: /(\.|\/)(jpg|png|gif)$/i,
			uploadTemplateId: 'template-upload3',
            // The ID of the download template:
            downloadTemplateId: 'template-download3',
			filesContainer: '#containervignette',
			
			
			  });
	
	
	$('#fileupload').fileupload('option', {
            acceptFileTypes: /(\.|\/)(wmv|ogg|webm|mp4)$/i,
			
			  });
	

	

    // Enable iframe cross-domain access via redirect option:
    $('#fileupload').fileupload(
        'option',
        'redirect',
        window.location.href.replace(
            /\/[^\/]*$/,
            '/cors/result.html?%s'
        )
    );
	


    if (window.location.hostname === 'blueimp.github.com') {
        // Demo settings:
     /*   $('#fileupload').fileupload('option', {
            url: '//jquery-file-upload.appspot.com/',
            maxFileSize: 5000000,
            acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
            process: [
                {
                    action: 'load',
                    fileTypes: /^image\/(gif|jpeg|png)$/,
                    maxFileSize: 20000000 // 20MB
                },
                {
                    action: 'resize',
                    maxWidth: 1440,
                    maxHeight: 900
                },
                {
                    action: 'save'
                }
            ]
        });*/
        // Upload server status check for browsers with CORS support:
        if ($.support.cors) {
            $.ajax({
                url: '//jquery-file-upload.appspot.com/',
                type: 'HEAD'
            }).fail(function () {
                $('<span class="alert alert-error"/>')
                    .text('Upload server currently unavailable - ' +
                            new Date())
                    .appendTo('#fileupload');
            });
			
			  $.ajax({
                url: '//jquery-file-upload.appspot.com/',
                type: 'HEAD'
            }).fail(function () {
                $('<span class="alert alert-error"/>')
                    .text('Upload server currently unavailable - ' +
                            new Date())
                    .appendTo('#fileupload2');
            });
			
			 $.ajax({
                url: '//jquery-file-upload.appspot.com/',
                type: 'HEAD'
            }).fail(function () {
                $('<span class="alert alert-error"/>')
                    .text('Upload server currently unavailable - ' +
                            new Date())
                    .appendTo('#fileupload3');
            });
			
        }
    } else {
        // Load existing files:
        $.ajax({
            // Uncomment the following to send cross-domain cookies:
            //xhrFields: {withCredentials: true},
            url: $('#fileupload').fileupload('option', 'url'),
            dataType: 'json',
            context: $('#fileupload')[0]
        }).done(function (result) {
            if (result && result.length) {
                $(this).fileupload('option', 'done')
                    .call(this, null, {result: result});
            }
        });
		
		  $.ajax({
            // Uncomment the following to send cross-domain cookies:
            //xhrFields: {withCredentials: true},
            url: $('#fileupload2').fileupload('option', 'url'),
            dataType: 'json',
            context: $('#fileupload2')[0]
        }).done(function (result) {
            if (result && result.length) {
                $(this).fileupload('option', 'done')
                    .call(this, null, {result: result});
            }
        });
		
		 $.ajax({
            // Uncomment the following to send cross-domain cookies:
            //xhrFields: {withCredentials: true},
            url: $('#fileupload3').fileupload('option', 'url'),
            dataType: 'json',
            context: $('#fileupload3')[0]
        }).done(function (result) {
            if (result && result.length) {
                $(this).fileupload('option', 'done')
                    .call(this, null, {result: result});
            }
        });
		
    }

});
